package com.java.basis.copy;

/**
 * @author wangning
 * @create 2021-11-24 16:17
 */
class Professor implements Cloneable {
	public Object clone() {
		Professor p = null;
		try {
			p =  (Professor) super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return p;
	}

}
public class Student implements Cloneable {
	String name;
	int age;
	Professor professor;

	public Student (String name, int age, Professor professor) {
		this.name = name;
		this.age = age;
		this.professor = professor;
	}

	public Object clone() {
		Student o = null;
		try {
			o =  (Student)super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		assert o != null;
		o.professor = (Professor) professor.clone();
		return o;
	}
}
